package ai

import (
	"fmt"

	http_label_center "gobase/http_work_flow/label_center"
	safetyx "gobase/http_work_flow/label_center/ai/safety"
	"gobase/logger"
)

// 数据转绘制
func Data2Safety(value *safetyx.RespAiSafety, id_scheme int) (_frame http_label_center.Tag, _err error) {
	var metas = make([]http_label_center.Meta, 0)
	if len(value.ResultValue.ResultDetail.ResultItems) == 0 {
		_err = fmt.Errorf("检测，没有结果")
		return
	}
	for _, v := range value.ResultValue.ResultDetail.ResultItems {
		var meta = http_label_center.Meta{
			X:           int64(v.LeftTopX),
			Y:           int64(v.LeftTopY),
			Remark:      "冀北安全(省)",
			StrokeStyle: "rgb(255,0,0)",
			TypeId:      id_scheme,
			// ProtoWidth:  1920,
			// ProtoHeight: 1080,
			Rect: &http_label_center.Rect{
				Width:  int64(v.RightBottomX - v.LeftTopX),
				Height: int64(v.RightBottomY - v.LeftTopY),
				Text:   value.ResultValue.ResultDetail.ResultDesc,
				Center: false,
			},
		}
		switch value.ResultValue.ResultDetail.ResultDesc {
		case "011_wz_xwwz_wdaqm":
			meta.Rect.Text = "未戴安全帽"
		case "011_wz_xwwz_wgfzz":
			meta.Rect.Text = "未规范着装"
		default:
			logger.Debugf("新的返回标识:IdScheme:[%d] ResultDesc:[%s]", id_scheme, value.ResultValue.ResultDetail.ResultDesc)
		}
		metas = append(metas, meta)
	}
	_frame = http_label_center.Tag{
		Metas: metas,
		AbsoluteTime: &http_label_center.AbsoluteTime{
			CenterUnixMs: 0, //抽图毫秒时间
			DurationMs:   2000,
		},
	}
	return
}
